package com.zjun.demo.experimentaldemo.indexbar

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.zjun.demo.experimentaldemo.indexbar.suspension.ISuspensionInterface
import java.io.Serializable

@JsonClass(generateAdapter = true)
data class CountryEntity(
    @Json(name = "area_code")
    val areaCode: String = "",
    @Json(name = "id")
    val id: Int,
    @Json(name = "name")
    val name: String,
    @Json(name = "num_code")
    val numCode: String = "",
    @Json(name = "region")
    val region: String,
    @Json(name = "three_code")
    val threeCode: String,
    @Json(name = "two_code")
    val twoCode: String,
    @Json(name = "isSelected")
    val isSelected:Boolean = false
) : ISuspensionInterface, Serializable {

    @Json(name = "mIsShowSuspension")
    var mIsShowSuspension:Boolean = false

    override fun getSuspensionTag(): String {
        return when (IndexBarActivity.language) {
            "zh" -> PinyinUtil.getFirstLetter(name)
            "de" -> name.first().toString()
            "es" -> name.first().toString()
            "fr" -> name.first().toString()
            "ja" -> name.first().toString()
            "it" -> name.first().toString()
            else -> try {
                name.first().uppercase()
            } catch (e: Exception) {
                "#"
            }

        }
    }

    override fun isShowSuspension(): Boolean = mIsShowSuspension

     fun setShowSuspension(isShowSuspension:Boolean){
         mIsShowSuspension = isShowSuspension
     }

}